// Source code is decompiled from a .class file using FernFlower decompiler.
import java.awt.FlowLayout;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JFileChooser;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.io.IOException;

public class MyGUI {
   public MyGUI() {
   }

   public static void main(String[] var0) {
      JFrame var1 = new JFrame("王者荣耀");
      JButton var2 = new JButton("上号");
      var2.addActionListener((var1x) -> {
         JOptionPane.showMessageDialog(var1, "TimiTimi!");
         // 选择文件
         JFileChooser fileChooser = new JFileChooser();
         fileChooser.setDialogTitle("请选择好友名单文件");
         int result = fileChooser.showOpenDialog(var1);
         if (result != JFileChooser.APPROVE_OPTION) {
            JOptionPane.showMessageDialog(var1, "未选择文件，操作取消。");
            return;
         }
         java.util.List<String> friends;
         try {
            friends = Files.readAllLines(fileChooser.getSelectedFile().toPath());
         } catch (IOException e) {
            JOptionPane.showMessageDialog(var1, "读取好友名单失败！\n" + e.getMessage());
            return;
         }
         if (friends.isEmpty()) {
            JOptionPane.showMessageDialog(var1, "没有在线好友可邀请。");
            return;
         }
         Object selected = JOptionPane.showInputDialog(
            var1,
            "选择要邀请的好友：",
            "邀请好友",
            JOptionPane.PLAIN_MESSAGE,
            null,
            friends.toArray(),
            friends.get(0)
         );
         if (selected != null) {
            JOptionPane.showMessageDialog(var1, "已邀请：" + selected);

            // 增加“开始游戏”按钮
            JButton startButton = new JButton("开始游戏");
            startButton.addActionListener(e2 -> {
                JOptionPane.showMessageDialog(var1, "开始掉分！");
            });
            var1.add(startButton);
            var1.revalidate(); // 刷新界面
            var1.repaint();
         }
      });
      var1.setLayout(new FlowLayout());
      var1.add(var2);
      var1.setSize(300, 200);
      var1.setDefaultCloseOperation(3);
      var1.setVisible(true);
   }
}
